package com.test.demo.javabasis.example;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class JsonParserParent {
    public static void main(String[] args) {
        Son son = new Son();
        son.setSon("son");
        son.setParent("parent");
        List<Son> objects = new ArrayList<>();
        objects.add(son);
        String s = JSONArray.toJSONString(objects);

        List<Son> sons = JSONArray.parseArray(s, Son.class);
        System.out.println(sons.toString());
    }
}

interface Par{

}

abstract class Parent implements Par{
    private String parent;

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }
}

class Son extends Parent{

    private String son;

    public String getSon() {
        return son;
    }

    public void setSon(String son) {
        this.son = son;
    }
}